#ifndef SIPCORE_H
#define SIPCORE_H

#include <QObject>
#include <QMap>
#include <pjsua-lib/pjsua.h>

class SipCore : public QObject
{
	Q_OBJECT

public:
	SipCore(QObject *parent);
	~SipCore();

public:
	pj_status_t registerSipAccount(const char *callerid, const char *username, const char *password, const char *domain);
	pj_status_t unRegisterSipAccount(const char *callerid);
	pj_status_t callAnswer(pjsua_call_id call_id);

signals:
	void errorMessage(QString msg);
    void evtCallAnswer(int call_id);

private:
	pj_status_t initail(void);
	pj_status_t setUdpTransPort(unsigned port);
	pj_status_t errorExit(const char *title, pj_status_t status);

private:
	static void onEventIncomingCall(pjsua_acc_id acc_id, pjsua_call_id call_id,pjsip_rx_data *rdata);
	static void onEventCallMediaState(pjsua_call_id call_id);
	static void onEventCallState(pjsua_call_id call_id, pjsip_event *e);

private:
	QMap<QString,pjsua_acc_id> m_AccountID_Map;
};

#endif // SIPCORE_H
